package nl.rug.snitter.message;

import nl.rug.snitter.db.CommonDbCommands;
import nl.rug.snitter.user.User;



public class SiteMessagePropagation implements MessagePropagation
{

	private static final long serialVersionUID = 1001247970633989741L;
	
	@Override
	/**
	 * This method will save the data to the db
	 */
	public void execute(Long idToSeeNewMsg, Long idPostingNewMsg, Long msgId)
	{
		User seeUser= CommonDbCommands.getUser(idToSeeNewMsg, true, true, null);
		seeUser.addNewMsgFrom(idPostingNewMsg, 1l);	
		CommonDbCommands.UpdateUser(seeUser);
	}

	@Override
	/**
	 * This method will save the data to the db
	 */
	public void execute(User userToSeeNewMsg, User userPostingNewMsg, Long msgId)
	{
		userToSeeNewMsg.addNewMsgFrom(userPostingNewMsg.getId(), 1l);
		CommonDbCommands.UpdateUser(userToSeeNewMsg);
	}

}
